/**
 * 此页面比传user_id
 * */
var Volunteer = {
	User_id:fnBase.splitURL()['user_id'],
	init: function() {
		//this.DataPie(); //有数据
		//this.NoneDataPie();
		this.AddEvent();
		this.GetVolunteerCollege();
	},
	GetVolunteerCollege:function(){
		var myBodyBox=document.getElementById('mybody_box');
		var loadingMask = document.getElementById('cssload');
		var isUser='';
		if(!fnBase.isLogin(Volunteer.User_id)) {
			//fnBase.toast('亲！您未登陆');
			isUser='';
			Volunteer.NoneDataPie();
			Volunteer.GetRecommendSchool();
			loadingMask.parentNode.removeChild(loadingMask);
			myBodyBox.style.visibility='visible';
		}else{
			isUser=Volunteer.User_id;
			fnBase.commonAjax(fnBase.api.VolunteerCollege,{"user_id":isUser},function(data){
			//console.log(data)
			if(data.code==0){
				var datal=data.data;
				if(datal.setup==0){
					Volunteer.NoneDataPie();
					Volunteer.GetRecommendSchool(datal);
				}else{
					//保底ensure   稳妥safe    冲刺sprint
					Volunteer.DataPie(datal);
					Volunteer.GetRecommendSchool(datal);
				}
			}else{
				Volunteer.NoneDataPie();
				Volunteer.GetRecommendSchool(datal);
			}
			loadingMask.parentNode.removeChild(loadingMask);
			myBodyBox.style.visibility='visible';
			});
		}
	},
	AddEvent:function(){
		function closeTime(){
			$('#closeModal').hide();
		};
		setTimeout(closeTime,3000);
		$('.header-close').click(function(){
			$(this).parent().hide();
		});
		//院校查询
		$('#subSchoolInquire').on('click',function(){
			//fnBase.toast('院校查询');
			if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
					if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
						GoToLogin();
					} else if(fnBase.versions.android) {
						window.myObj.toLogin();
					}
					return false;
				};
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				SearchSchool();
			} else if(fnBase.versions.android) {
				window.myObj.schoolSelect();
			}
			
			
		});
		//专业查查
		$('#subMajorInquire').on('click',function(){
			//fnBase.toast('专业查询');
			if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					GoToLogin();
				} else if(fnBase.versions.android) {
					window.myObj.toLogin();
				}
				return false;
			};
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				SearchMajor();
			} else if(fnBase.versions.android) {
				window.myObj.majorSelect();
			}
			
		});
		//批次线查询
		$('#subLineInquire').on('click',function(){
			//fnBase.toast('批次线查询'Sprint==0Sprint==0);
			if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
					if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
						GoToLogin();
					} else if(fnBase.versions.android) {
						window.myObj.toLogin();
					}
					return false;
				};
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				SearchBatchLine();
			} else if(fnBase.versions.android) {
				window.myObj.batchSelect();
			}
			
		});
	},
	//无数据的甜甜圈
	NoneDataPie: function() {
		var myChart = echarts.init(document.getElementById('main'));
		var option = {
			title: {},
			grid: { //CANVAS 距离
				top: '0%',
				left: '0%',
				right: '0%',
			},
			tooltip: {
				trigger: 'item',

			},
			color: ['#85d528', '#ff6d00', '#ffbe00'],
			legend: {
				orient: 'vertical',
				x: 'left',

			},
			calculable: false,
			 series:[{
					type: 'pie',
					radius: ['50%', '65%'],
					center: ['50%', '50%'],
					label: {
						normal: {
							show: false,
						}
					},
					silent: true,
					labelLine: {
						normal: {
							show: false
						}
					},
					data: [{
						itemStyle: {
							normal: {
								color: '#f4f4f4',

							}
						}
					}],

				}, {
					z: 10,
					type: 'pie',
					radius: ['0%', '48%'],
					hoverAnimation: false,
					legendHoverLink: false,
					//silent: true,  //是否响应鼠标事件
					center: ['50%', '50%'],
					clockwise: true, //是否顺时针渲染
					tooltip: { //提示框
						show: false,
					},
					labelLine: {
						normal: {
							show: false
						}
					},
					data: [{
						value: 100,
						name: '点击输入分数\n',
						label: {
							normal: {
								position: 'center',
								show: true,
								textStyle: {
									fontSize: '14',
									color: '#fa4846'
								}
							}
						},
						itemStyle: {
							normal: {
								color: 'rgba(300,300,300,1)',
								shadowBlur: 5,
								shadowColor: 'rgba(0,176,255,1)'
							}
						}
					}, {
						value: 0,
						name: '000',
						label: {
							normal: {
								position: 'center',
								show: true,
								textStyle: {
									fontSize: '25',

									color: '#6b6b6b'
								}
							}
						},
						itemStyle: {
							normal: {
								color: 'rgba(300,300,300,1)',
								shadowBlur: 5,
								shadowColor: 'rgba(0,176,255,1)'
							}
						}
					}, {
						value: 0,
						name: '城市 | 科目',
						label: {
							normal: {
								position: 'center',
								show: true,
								textStyle: {
									fontSize: '15',
									color: '#6b6b6b'
								}
							}
						},
						itemStyle: {
							normal: {
								color: 'rgba(300,300,300,1)',
								shadowBlur: 5,
								shadowColor: 'rgba(0,176,255,1)'
							}
						}

					},]
				},
			]
		};
		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);
		myChart.on('click', function(params) {
			//console.log(params)
			if(params.seriesIndex === 1) { //点击园中心区域
				if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
					if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
						GoToLogin();
					} else if(fnBase.versions.android) {
						window.myObj.toLogin();
					}
					return false;
				};
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					Go2SetInfo();
				} else if(fnBase.versions.android) {
					window.myObj.toSetMark();
				}
				
				//console.log(params.seriesIndex === 1);
			}
		});
	},
	//有数据的甜甜圈//保底ensure   稳妥safe    冲刺sprint
	DataPie: function(datal) {
		//console.log(datal);
		var SubJect='',prov_Name='',enStatus,saStatus,spStatus;
		if(datal.subject==1){SubJect='文科';}else if(datal.subject==2){SubJect='理科';}else if(datal.subject==3){SubJect='综合';}else{SubJect='其他';}
		var Ensure=parseInt(datal.ensure);
		var Safe=parseInt(datal.safe);
		var Sprint=parseInt(datal.sprint);
		if(Ensure==0){enStatus=false};
		if(Safe==0){saStatus=false};
		if(Sprint==0){spStatus=false};
		if(Sprint==0&&Safe==0&&Ensure==0){
			enStatus=true;
			saStatus=true;
			spStatus=true;
		}
		prov_Name=datal.prov_name;
		var mark=datal.mark;
		var myChart = echarts.init(document.getElementById('main'));
		// 指定图表的配置项和数据
		var option = {
			calculable: false,
			series: [{
					//name: '访问来源',
					type: 'pie',
					radius: ['50%', '65%'],
					hoverAnimation: false, //滑动动画
					minAngle: 0, //最小扇区角度
					data: [{
							value: Ensure,
							name: '保一保\n院校',
							label:{
								normal:{
									show:enStatus,
								}
							},
							labelLine:{
								normal:{
									show:true,
									smooth: false, //视觉引导线平滑
								}
							},
							itemStyle:{
								normal:{
									color:'#85d528',
								}
							},

						}, {
							value: Safe,
							name: '稳一稳\n院校',
							label:{
								normal:{
									show:saStatus,
								}
							},
							labelLine:{
								normal:{
									show: saStatus,
									smooth: false, //视觉引导线平滑
								}
							},
							itemStyle:{
								normal:{
									color:'#ff6d00',
								}
							},
						}, {
							value:Sprint,
							name: '冲一冲\n院校',
							label:{
								normal:{
									show:spStatus,
								}
							},
							labelLine:{
								normal:{
									show: spStatus,
									smooth: false, //视觉引导线平滑
								}
							},
							itemStyle:{
								normal:{
									color:'#ffbe00',
								}
							},
						},
					]
				}, {
					z: 10,
					type: 'pie',
					radius: ['0%', '48%'],
					hoverAnimation: false,
					legendHoverLink: false,
					//silent: true,  //是否响应鼠标事件
					center: ['50%', '50%'],
					clockwise: true, //是否顺时针渲染
					tooltip: { //提示框
						show: false,
					},
					labelLine: {
						normal: {
							show: false
						}
					},
					data: [{
						value: 100,
						name: '点击输入分数\n',
						label: {
							normal: {
								position: 'center',
								show: true,
								textStyle: {
									fontSize: '14',
									color: '#666666'
								}
							}
						},
						itemStyle: {
							normal: {
								color: 'rgba(300,300,300,1)',
								shadowBlur: 5,
								shadowColor: 'rgba(0,176,255,1)'
							}
						}
					}, {
						value: 0,
						name: mark,
						label: {
							normal: {
								position: 'center',
								show: true,
								textStyle: {
									fontSize: '27',
									color: '#6b6b6b'
								}
							}
						},
						itemStyle: {
							normal: {
								color: 'rgba(300,300,300,1)',
								shadowBlur: 5,
								shadowColor: 'rgba(0,176,255,1)'
							}
						}
					}, {
						value: 0,
						name: prov_Name + ' | ' + SubJect,
						label: {
							normal: {
								position: 'center',
								show: true,
								textStyle: {
									fontSize: '17',
									color: '#6b6b6b'
								}
							}
						},
						itemStyle: {
							normal: {
								color: 'rgba(300,300,300,1)',
								shadowBlur: 5,
								shadowColor: 'rgba(0,176,255,1)'
							}
						}

					}, ]
				},
			]
		};
		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);
		myChart.on('click', function(params) {
			if(params.seriesIndex === 1) { //点击园中心区域
				if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
					if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
						GoToLogin();
					} else if(fnBase.versions.android) {
						window.myObj.toLogin();
					}
					return false;
				};
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					Go2SetInfo();
				} else if(fnBase.versions.android) {
					window.myObj.toSetMark();
				}
				
				//console.log(params.seriesIndex === 1);
			}
		});
	},
	//根据推荐跳学校 //保底ensure   稳妥safe    冲刺sprint
	GetRecommendSchool:function(datal){
		//console.log(datal);
		if(datal){
			$('#Subensure .sub-num').text(datal.ensure);
			$('#Subsafe .sub-num').text(datal.safe);
			$('#Subsprint .sub-num').text(datal.sprint);
		}
		//保底
		$('#Subensure').click(function(){
			if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					GoToLogin();
				} else if(fnBase.versions.android) {
					window.myObj.toLogin();
				}
				return false;
			};
			//fnBase.toast('跳学校');
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				Go2FloorSchool();
			} else if(fnBase.versions.android) {
				window.myObj.endSchool();
			}
			
		});
		//稳妥
		$('#Subsafe').click(function(){
			if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					GoToLogin();
				} else if(fnBase.versions.android) {
					window.myObj.toLogin();
				}
				return false;
			};
			//fnBase.toast('跳学校');
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				Go2SafeSchool();
			} else if(fnBase.versions.android) {
				window.myObj.safeSchool();
			}
		});
		//冲刺
		$('#Subsprint').click(function(){
			if(!fnBase.isLogin(Volunteer.User_id)) {
				//fnBase.toast('亲！您未登陆');
				if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
					GoToLogin();
				} else if(fnBase.versions.android) {
					window.myObj.toLogin();
				}
				return false;
			};
			//fnBase.toast('跳学校');
			if(fnBase.versions.ios || fnBase.versions.iPhone || fnBase.versions.iPad) {
				Go2SprintSchool();
			} else if(fnBase.versions.android) {
				window.myObj.sprintSchool();
			}
		});
	},
}
$(document).ready(function() {
	Volunteer.init();
});